require 'timeout'
require "#{RAILS_ROOT}/lib/agent_tcp.rb"

PORT = 1234

class AgentWorker < BackgrounDRb::Worker::RailsBase
   
  def do_work(args)
    Computer.find(:all).each do |computer|
      atcp = AgentTcp.new(computer.id, PORT)
      atcp.ping
    end
    logger.info("Work done !")
  rescue Timeout::Error
    Incident.timeout(computer.id)
  end

end
AgentWorker.register
